int control; //input in ASCII


void setup(){
  
  Serial.begin(9600);
  pinMode(9,OUTPUT);
  pinMode(10,OUTPUT);
  pinMode(11,INPUT);

}

void loop(){
 
  if (Serial.available() > 0) {
    
    if(digitalRead(11)==HIGH)//if all doors are closed {
    
      control=Serial.read(); // read input from Serial Monitor
  
  switch(control){
    case 76:// if the input is L (Lock door)
      digitalWrite(9, HIGH); //LED D9 turn on
      digitalWrite(10, HIGH); //LED D10 (notification) blink for 1 sec
      delay(1000);
      digitalWrite(10, LOW);
      break;
      
    case 85: //if the input is U (Unlock door)
      digitalWrite(9, LOW); //LED D9 turn off
      digitalWrite(10, HIGH); //LED D10 (notification) blink for 1 sec twice
      delay(1000);
      digitalWrite(10, LOW);
      delay(1000);
      digitalWrite(10, HIGH);
      delay(1000);
      digitalWrite(10, LOW);
      break;
  }
    }
    
    else // some doors still open {
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
      
    }
  
  }
}



